package com.spark.usermusicService.controller;


import com.spark.R;
import com.spark.usermusicService.entity.User;
import com.spark.usermusicService.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 用户信息 前端控制器
 * </p>
 *
 * @author wzk
 * @since 2021-07-01
 */
@RestController
@RequestMapping("/usermusicService/user")
@CrossOrigin
public class UserController {
    @Autowired
    UserService userService;

    @GetMapping("/info/{id}")
    public R findInfoById(@PathVariable("id") String id) {
        User user = userService.getInfoById(id);
        return R.ok().data("items", user);
    }

//    @GetMapping("/info")
//    public R findInfoById(@RequestParam("id") String id) {
//        User user = userService.getInfoById(id);
//        return R.ok().data("items", user);
//    }

    @PostMapping("/info/update")
    public R updateInfoById(@RequestBody() User user) {
        boolean b = userService.updateById(user);
        return R.ok();
    }

    @GetMapping("/delete/{id}")
    public R deleteUserById(@PathVariable("id") String id) {
        boolean b = userService.deleteById(id);
        return R.ok();
    }
}

